package com.zh.freechat.domain.op_log.entity;

import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import com.zh.webcommon.common.auditor.mp.SimpleEntity;
import lombok.Getter;
import lombok.Setter;

/**
 * @author ZH
 * @date 16:07 2021/11/5
 */
@Getter
@Setter
@TableName("log_operate") //range分区
public class OperateLogRecord extends SimpleEntity {
    @TableId(type = IdType.AUTO)
    private Long id;

    /**
     * 访问的方法
     */
    private String accessMethod;

    /**
     * 操作内容
     */
    private String operation;
    /**
     * 操作用户
     */
    private String username;

    /**
     * 访问IP
     */
    private String remoteHost;

    /**
     * 访问的请求参数
     */
    private String queryParams;

    private String tenantId;

    protected OperateLogRecord() {
    }

    /**
     * 创建操作日志
     *
     * @param remoteHost   访问IP
     * @param operation    操作内容
     * @param accessMethod 访问的方法
     */
    public OperateLogRecord(String remoteHost, String operation, String accessMethod) {
        this(remoteHost, operation, accessMethod, "{}");
    }

    /**
     * 创建操作日志
     *
     * @param remoteHost   访问IP
     * @param operation    操作内容
     * @param accessMethod 访问的方法
     * @param queryParams  访问的请求参数
     */
    public OperateLogRecord(String remoteHost, String operation, String accessMethod, String queryParams) {
        this.remoteHost = remoteHost;
        this.operation = operation;
        this.accessMethod = accessMethod;
        this.queryParams = queryParams;
    }
}
